package com.pianzhu.blockchainemr.service.impl;

import com.pianzhu.blockchainemr.mapper.UserMapper;
import com.pianzhu.blockchainemr.pojo.User;
import com.pianzhu.blockchainemr.service.UserService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public void getUserById(Long id) {

    }

    @Override
    public User getUserByUsername(String username) {
        User user = userMapper.selectByUsername(username);
        if (user == null) {
            return null;
        }
        return user;
    }

    @Override
    public void changePassword(User user) {
        user.setLastLoginTime(LocalDateTime.now());
        userMapper.updatePassword(user);
    }
}
